package com.yj.suncity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;
import cn.jpush.android.api.JPushInterface;

public class LaunchActivity extends Activity {
	
	protected static final String TAG = "LaunchActivity";
	private Animation mAnimation_Alpha;
	private ImageView mMainImageView;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.getWindow().setFlags
		(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.activity_launch);
	
		mMainImageView = (ImageView) findViewById(R.id.img);
		
		JPushInterface.init(getApplicationContext());
//		JPushInterface.setAlias(LaunchActivity.this, SharedPreferencesUtil.getInstance().getString(LaunchActivity.this,
//				ShareCon.USERFILE, ShareCon.USERPHONE, ""), null);
		JPushInterface.resumePush(LaunchActivity.this);
		
		loadView();
	}

	private void loadView() {
	     //  long startTime = Calendar.getInstance().getTimeInMillis();
	       
	       mAnimation_Alpha = new AlphaAnimation(0.1f, 1.0f);
	       mAnimation_Alpha.setDuration(3000);
	       mMainImageView.setAnimation(mAnimation_Alpha);
			
		LoadViewAnimationListener animationListener = new LoadViewAnimationListener();
		mAnimation_Alpha.setAnimationListener(animationListener);
	}

	class LoadViewAnimationListener implements AnimationListener {
		@Override
		public void onAnimationEnd(Animation animation) {
			// TODO Auto-generated method stub
			Intent intent = new Intent();
			intent.setClass(LaunchActivity.this,MainActivity.class);
			startActivity(intent);
			finish();
		}

		@Override
		public void onAnimationRepeat(Animation animation) {
			// TODO Auto-generated method stub

		}

		@Override
		public void onAnimationStart(Animation animation) {
			// TODO Auto-generated method stub

		}

	}
	@Override
    protected void onResume() {
        super.onResume();
        JPushInterface.onResume(getApplicationContext());
    }
    @Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		JPushInterface.onPause(getApplicationContext());
	}

}
